package pers.fjl.test.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import pers.fjl.common.entity.QueryPageBean;
import pers.fjl.common.po.Supplier;
import pers.fjl.test.dao.SupplierDao;
import pers.fjl.test.service.SupplierService;
import javax.annotation.Resource;


@Service
public class SupplierServiceImpl extends ServiceImpl<SupplierDao, Supplier> implements SupplierService {
    @Resource
    private SupplierDao supplierDao;

    @Cacheable(value = {"SupplierMap"})
    public Page<Supplier> findPage(QueryPageBean queryPageBean) {
        //设置分页条件
        Page<Supplier> page = new Page<>(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        //设置查询条件
        QueryWrapper<Supplier> wrapper = new QueryWrapper<>();
        wrapper.like(queryPageBean.getQueryString() != null, "supplier", queryPageBean.getQueryString());
        return supplierDao.selectPage(page, wrapper);
    }
}
